package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.ProvinceBiz;
import com.egao.orderB.entity.Province;
import com.egao.orderB.service.ProvinceService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

//import com.egao.orderB.mapper.ProvinceMapper;
//import javax.transaction.Transactional;

/**
 * 省服务实现类
 * @author : Doman
 * @date : 2020-10-20 15:39:20
 * @version ：1.0
 */
@Service
public class ProvinceServiceImpl /*extends ServiceImpl<ProvinceMapper, Province> */implements ProvinceService {

	@Autowired
	private ProvinceBiz provinceBiz;

    /**
    @Override
    public PageResult<Province> listPage(PageParam<Province> page) {
        List<Province> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Province> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Province province, User loginUser)  throws Exception{
        return provinceBiz.list(page,province,loginUser);
    }

    @Override
    public JsonResult list(Province province, User loginUser) {
        return JsonResult.ok().setData(provinceBiz.list(province,loginUser));
    }

    @Override
    public JsonResult getById(Province province) {
        return JsonResult.ok().setData(provinceBiz.getById(province));
    }

    @Override
    public JsonResult save(Province province, User loginUser) {
        if (provinceBiz.save(province, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Override
    public JsonResult update(Province province, User loginUser) {
        if (provinceBiz.update(province, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult remove(Province province, User loginUser) {
        if (provinceBiz.remove(province, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
